/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ages.test.swat

import com.ages.env.AbstractWorld
import com.ages.env.GLWindow
import com.ages.input.Keyboard
import com.ages.input.Mouse
import com.ages.math.Vector3D
import com.ages.test.Box
import com.ages.test.HelloWorldWorld
import scala.util.Random
import com.ages.graphics.Sprite

object SWAT{


//    val spr2:Sprite = new Sprite("/com/ages/test/res/picnicjello.png",1,1,1)
//    val spr3:Sprite = new Sprite("/com/ages/test/res/picnicjello.png",1,1,1)
//    val spr4:Sprite = new Sprite("/com/ages/test/res/picnicjello.png",1,1,1)
//    val spr5:Sprite = new Sprite("/com/ages/test/res/picnicjello.png",1,1,1)
//    val spr6:Sprite = new Sprite("/com/ages/test/res/picnicjello.png",1,1,1)

  val version = "0.0.9"
  val mouse = new Mouse
  val keys = new Keyboard
  val rnd = new Random

  def main(args:Array[String])
  {
    val world = newGame
    var skipLoading = false
    if(args.size==1)
      {
        skipLoading = if(args(0).equals("skip_loading")) true else false
      }
    for(x <- 1 to 300)
      {
        if(!skipLoading)
          {
          val spr1 = new Sprite("/com/ages/test/res/wasp1.png",1,1,1)
          }
      }
    val loadingWorld = new LoadingWorld()
    loadingWorld.setSuccessor(world)


    val gameWindow:GLWindow = new GLWindow("S.W.A.T. - v"+version,loadingWorld,800,620)
    gameWindow.addKeylistener(keys)
    gameWindow.addMouselistener(mouse)
    gameWindow.hideMouse

    println("------------------")
    println("Welcome to")
    println("S.W.A.T. v."+version)
    println("------------------")
  }

  def newGame():AbstractWorld={

    val player = new Swatter(new Vector3D(0,0,0),mouse,keys)
    val world:AbstractWorld = new SwatWorld(player)

    world.addEntity(new Fly(new Vector3D(800*rnd.nextDouble,600*rnd.nextDouble,0)))
    world.addEntity(new Fly(new Vector3D(800*rnd.nextDouble,600*rnd.nextDouble,0)))
    world.addEntity(new Wasp(new Vector3D(800*rnd.nextDouble,600*rnd.nextDouble,0)))
    world.addEntity(player)
    
    world
  }

}
